/*
 * @Author: lijunqing
 * @Date: 2024-04-18 15:37:31
 * @LastEditors: lijunqing
 * @LastEditTime: 2024-04-18 15:54:53
 * @Description:
 */
const http = require("http");

/* // 使用http模块发送get请求
http.get("http://localhost:8000", (res) => {
  // 给我们的是可读流

  console.log();
  res.setEncoding("utf-8");

  res.on("data", (data) => {
    console.log(JSON.parse(data));
  });
});
 */

// 发送post请求

const req = http.request(
  {
    method: "post",
    hostname: "localhost",
    port: 8000,
  },
  (res) => {
    res.on("data", (data) => {
      data.toString();
      console.log(JSON.parse(data.toString()));
    });
  }
);
// 必须调用end 表示内容写入完毕
req.end();
